home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 1
/
Amiga Tools.iso
/
egs-tools
/
egs_demo-version
/
egs_devels
/
examples
/
beginner_gadgets
/
gadget4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-06
|
5KB
|
161 lines
/**************************************************************************
***** Gadget Demo 4 *****
***** *****
***** by John J. Karcher *****
***** *****
***** 10 August 1992 *****
***** 10 Jan 1993 mvk *****
***** *****
**************************************************************************/
/*
This program opens up a window with three gadgets in it, using
egsgadbox.library. Each gadget prints its own message to the
console.
This demonstrates how to use CreateHorizBox() to get multiple
gadgets, and react to different action gadget messages.
*/
#include <stdio.h>
#include <exec/types.h>
#include <egs/egsintui.h>
#include <egs/egsgadbox.h>
#include <proto/all.h>
#include <egs/proto/all.h>
#define ACTION_GAD_ID 1000
#define HELP_GAD_ID 1001
#define LONG_GAD_ID 1002
BYTE CreateWindow(void);
BYTE CreateGfx(void);
struct Library *EGSIntuiBase;
struct Library *EGBBase;
struct EB_GadContextNode *GadCon;
struct EI_Window *Win;
BYTE CreateGfx(void)
{
EB_GadBoxPtr root, b1;
BYTE ret = 0;
if (GadCon = EB_CreateGadContext(NULL, NULL, -1, -1))
{
root = EB_CreateVertiBox(GadCon);
EB_AddLastSon(root, EB_CreateVertiFill(GadCon, TRUE, 0));
b1 = EB_CreateHorizBox(GadCon);
EB_AddLastSon(root, b1);
EB_AddLastSon(b1, EB_CreateHorizFill(GadCon, TRUE, 0));
EB_AddLastSon(b1, EB_CreateTextAction(GadCon, "_Push Me", ACTION_GAD_ID, EB_FILL_ALL));
EB_AddLastSon(b1, EB_CreateHorizFill(GadCon, TRUE, 0));
EB_AddLastSon(b1, EB_CreateTextAction(GadCon, "_Leave Me Alone", LONG_GAD_ID, EB_FILL_ALL));
EB_AddLastSon(b1, EB_CreateHorizFill(GadCon, TRUE, 0));
EB_AddLastSon(b1, EB_CreateTextAction(GadCon, "_Help Me", HELP_GAD_ID, EB_FILL_ALL));
EB_AddLastSon(b1, EB_CreateHorizFill(GadCon, TRUE, 0));
EB_AddLastSon(root, EB_CreateVertiFill(GadCon, TRUE, 0));
root = EB_CreateMasterWindow(GadCon,Win,root);
if (EB_ProcessGadBoxes(GadCon, root))
{
ret = 1;
}
}
return ret;
}
BYTE CreateWindow(void)
{
BYTE ret = 0;
if (CreateGfx())
{
GadCon->NewWin->Title = "EGS Gadget Demo 4";
GadCon->NewWin->Flags &= ~EI_SMART_REFRESH;
GadCon->NewWin->Flags |= (EI_SIZEBBOTTOM | EI_WINDOWCENTER);
GadCon->NewWin->IDCMPFlags |= (EI_iCLOSEWINDOW | EI_iGADGETUP | EI_iSIZEVERIFY | EI_iNEWSIZE);
GadCon->NewWin->Bordef.SysGadgets |= (EI_WINDOWCLOSE | EI_WINDOWSIZE);
if (Win = EI_OpenWindow(GadCon->NewWin))
{
ret = 1;
}
}
return ret;
}
main()
{
struct EI_EIntuiMsg *IMsg;
struct EI_Gadget *TempGad;
BYTE quit = 0;
if (EGSIntuiBase = OpenLibrary("egsintui.library", 0))
{
if (EGBBase = OpenLibrary("egsgadbox.library", 0))
{
if (CreateWindow())
{
while (!quit)
{
WaitPort(Win->UserPort);
if (IMsg = (struct EI_EIntuiMsg *)GetMsg(Win->UserPort))
{
if (IMsg->Class == EI_iCLOSEWINDOW)
{
quit = 1;
}
if (IMsg->Class == EI_iGADGETUP)
{
TempGad = (struct EI_Gadget *)IMsg->IAddress;
if (TempGad->GadgetID == ACTION_GAD_ID)
{
printf("You pressed me!\n");
}
if (TempGad->GadgetID == LONG_GAD_ID)
{
printf("You're not leaving me alone!\n");
}
if (TempGad->GadgetID == HELP_GAD_ID)
{
printf("You helped me!\n");
}
}
if (IMsg->Class == EI_iSIZEVERIFY)
{
EI_RemoveGList(Win, GadCon->First, GadCon->Num);
EB_DeleteGadContext(GadCon);
GadCon = NULL;
}
if (IMsg->Class == EI_iNEWSIZE)
{
EI_LockIntuition();
CreateGfx();
if (GadCon)
{
EI_AddGList(Win, GadCon->First, GadCon->Num);
}
EI_UnlockIntuition();
}
ReplyMsg((struct Message *)IMsg);
}
}
}
if (Win) EI_CloseWindow(Win);
if (GadCon) EB_DeleteGadContext(GadCon);
CloseLibrary(EGBBase);
}
CloseLibrary(EGSIntuiBase);
}
}